package com.newblog.json;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class JsonObject {
	private Map map = new HashMap();
	private void put(String key,Object value){
		this.map.put("\""+key+"\"", value);
	}
	private String get(String key){
		return (String)this.map.get("\""+key+"\"");
	}
	
	public String toString(){
	    Set set = map.keySet();
	    StringBuffer sb = new StringBuffer();
	    String key  = null;
	    String value = null;
	    sb.append("{");
	    for(Iterator iter = set.iterator();iter.hasNext();){
	        key   =  (String)iter.next();
	        value =  (String)this.map.get(key);
	        sb.append("{"+key+":"+value+"}");
	        if(iter.hasNext())
	          sb.append(",");
	    }
	    sb.append("}");
	   return sb.toString(); 
	}
	public static void main(String[] args){
		JsonObject obj = new JsonObject();
		obj.put("a", "a\\a");
		obj.put("b", "bb");
		System.out.println(obj);
		String s="\"\\";
		for(int i=0;i<s.length();i++){
			System.out.println(s.charAt(i));
		}
		System.out.println(obj.get("a"));
	}
	

}
